#ifndef __LOG_H__
#define __LOG_H__

#include "crossplatform.h"
#include <intrin.h>
#include <malloc.h>
#include <string>
#include <stdio.h>
#include <string.h>

enum LogVerbosity
{
	LogError,
	LogWarning,
	LogInfo,
	LogDebug,
	LogVerbose,
	LogAll
};

#define STRINGIZE2(x) #x
#define STRINGIZE(x) STRINGIZE2(x)

#ifdef WIN32
#define _LOG(fmt, ...) printf(" (%04X) (%s:%d) " fmt "\n", GetCurrentThreadId(), STRINGIZE(FILE_ID), __LINE__, __VA_ARGS__)
#else
#include <sys/types.h>
#include <pthread.h>
#define _LOG(fmt, ...) printf(" (%04X) (%s:%d) " fmt "\n", (int)pthread_self() & 0xFFFF, STRINGIZE(FILE_ID), __LINE__, ## __VA_ARGS__)
#endif


#ifdef WIN32
#ifdef FILE_VERBOSITY
#define LOG(v, fmt, ...) {if(v < FILE_VERBOSITY) _LOG(fmt, __VA_ARGS__);}
#else
#define LOG(v, fmt, ...) _LOG(fmt, __VA_ARGS__)
#endif

#else
#ifdef FILE_VERBOSITY
#define LOG(v, fmt, ...) {if(v < FILE_VERBOSITY)_LOG(fmt, ## __VA_ARGS__);}
#else
#define LOG(v, fmt, ...) _LOG(fmt, ## __VA_ARGS__)
#endif
#endif


#endif
